using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Microsoft.Practices.CompositeUI.SmartParts;

namespace OrdersManager.Module.Tests.Mocks
{
	public class MockWorkspace : IWorkspace
	{
		private List<object> _smartParts = new List<object>();
        private object _closedSmartPart;

        public object ClosedSmartPart
        {
            get 
            { 
                return _closedSmartPart; 
            }
            set 
            { 
                _closedSmartPart = value; 
            }
        }

		public void Activate(object smartPart)
		{
		}

		public object ActiveSmartPart
		{
			get { return null; }
		}

		public void ApplySmartPartInfo(object smartPart, ISmartPartInfo smartPartInfo)
		{
		}

		public void Close(object smartPart)
		{
			_smartParts.Remove(smartPart);
			ClosedSmartPart = smartPart;
		}

		public void Hide(object smartPart)
		{
		}

		public void Show(object smartPart)
		{
			_smartParts.Add(smartPart);
		}

		public void Show(object smartPart, ISmartPartInfo smartPartInfo)
		{
			_smartParts.Add(smartPart);
		}

		public event EventHandler<WorkspaceEventArgs> SmartPartActivated;

		public void OnFireSmartPartActivated(object smartPart)
		{
			if (SmartPartActivated != null)
			{
				SmartPartActivated(this, new WorkspaceEventArgs(smartPart));
			}
		}

		public event EventHandler<WorkspaceCancelEventArgs> SmartPartClosing;

		public void OnFireSmartPartClosing(object smartPart)
		{
			if (SmartPartClosing != null)
			{
				SmartPartClosing(this, new WorkspaceCancelEventArgs(smartPart));
			}
		}

		public ReadOnlyCollection<object> SmartParts
		{
			get { return new ReadOnlyCollection<object>(_smartParts); }
		}
	}
}